package com.eskie.vmobileapp;

import java.util.ArrayList;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.actionbarsherlock.app.SherlockActivity;

public class ConfigActivity extends SherlockActivity {
	ListView lstView;
	ArrayAdapter<String> adapter;
	ArrayList<String> list;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_config);
		SharedPreferences pref = getSharedPreferences(CustomDialog.conf_pref, 0);
		GlobalVar.ID = pref.getString("saveID", "");
		GlobalVar.Gateway = pref.getString("saveGate", "");
		lstView = (ListView) findViewById(R.id.lstConf);
		list = new ArrayList<String>();
		list.add("ID Number");
		list.add("Gateway");
		list.add("Info");
		adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, list);
		lstView.setAdapter(adapter);
		
		lstView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				if (arg2==0)
					new CustomDialog(ConfigActivity.this, CustomDialog.IDNumber).start();
				else if (arg2==1)
					new CustomDialog(ConfigActivity.this, CustomDialog.Gateway).start();
				else{
					Toast.makeText(getApplicationContext(), "ID Number: " + GlobalVar.ID + " Gateway Number: " + GlobalVar.Gateway, Toast.LENGTH_LONG).show();
				}
			}
		});
	}
}
